
package com.anjiplus.template.gaea.business.modules.httptotransform.service.impl;

import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper;
import com.anjiplus.template.gaea.business.modules.httptotransform.controller.dto.HttpToTransformDto;
import com.anjiplus.template.gaea.business.modules.httptotransform.dao.HttpToTransformMapper;
import com.anjiplus.template.gaea.business.modules.httptotransform.dao.entity.HttpToTransform;
import com.anjiplus.template.gaea.business.modules.httptotransform.service.HttpToTransformService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Raod
 * @desc Http 数据集服务实现
 * @date 2021-03-18 12:11:31.150755900
 **/
@Service
//@RequiredArgsConstructor
@Slf4j
public class HttpToTransformServiceImpl implements HttpToTransformService {

    @Autowired
    private HttpToTransformMapper httpToTransformMapper;


    @Override
    public GaeaBaseMapper<HttpToTransform> getMapper() {
        return httpToTransformMapper;
    }


    @Override
    public List<HttpToTransform> getByTransFormId(String transFormId) {
        LambdaQueryWrapper<HttpToTransform> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(HttpToTransform::getId, transFormId);
        return httpToTransformMapper.selectList(wrapper);
    }

    @Override
    public List<HttpToTransform> getByHttpId(String httpId) {
        LambdaQueryWrapper<HttpToTransform> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(HttpToTransform::getHttpId, httpId);
        return httpToTransformMapper.selectList(wrapper);
    }

    @Override
    public Integer updateById(List<HttpToTransformDto> list) {
        for (HttpToTransformDto httpToTransformDto : list) {
            HttpToTransform httpToTransform = new HttpToTransform();
            BeanUtils.copyProperties(httpToTransformDto, httpToTransform);
            httpToTransformMapper.updateById(httpToTransform);
        }
        return 1;
    }

    @Override
    public void deleteByHttpId(String httpId) {
        LambdaQueryWrapper<HttpToTransform> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(HttpToTransform::getHttpId,httpId);
        httpToTransformMapper.delete(wrapper);
    }
}
